package com.netty.learn.aio;

import java.nio.ByteBuffer;
import java.nio.channels.AsynchronousSocketChannel;
import java.nio.channels.CompletionHandler;

public class AcceptCompletonHandler implements CompletionHandler<AsynchronousSocketChannel, AyncTimeServerHandler> {

	@Override
	public void completed(AsynchronousSocketChannel result, AyncTimeServerHandler attachment) {
		attachment.asynchronousServerSocketChannel.accept(attachment, this);
		ByteBuffer buffer = ByteBuffer.allocate(1024);
		result.read(buffer, buffer, new ReadCompletionHandler(result));
	}

	@Override
	public void failed(Throwable exc, AyncTimeServerHandler attachment) {
		attachment.latch.countDown();
		
	}

	

	

}
